﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows.Input;
using VMDS.Business.Entities;
using VMDS.GUIClient.Helper;
using VMDS.GUIClient.Model;

namespace VMDS.GUIClient.ViewModels.Management
{
    class StorageManagementViewModel:BaseViewModel
    {
        private bool _browserVisible;
        public bool BrowserVisible
        {
            get { return _browserVisible; }
            set { _browserVisible = value;OnPropertyChanged(()=>BrowserVisible); }
        } 
        public ObservableCollection<Storage> Storages
        {
            get { return ManagerDataStore.Instance.Storages; }
        }

        public ICommand AddStorage { get { return new BaseCommand(addstor); } }

        void addstor()
        {
            try
            {
                MsLocator.Client.AddStorage(new Storage(){Name = "blabla"});
                ManagerDataStore.Instance.Storages.Add(new Storage() { Name = "blabla" });
            }
            catch (Exception)
            {
                
                throw;
            }

            
        }

        private Storage _cstore;
        public Storage CurrentStorage
        {
            get { return _cstore; }
            set { _cstore = value; OnPropertyChanged(() => CurrentStorage);
                BrowserVisible = true;
            }
        }

        public StorageManagementViewModel()
        {
            ManagerDataStore.Instance.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Instance_PropertyChanged);
            BrowserVisible = false;
        }

        void Instance_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            OnPropertyChanged(()=>Storages);
        }
        

    }
}
